<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// +----------------------------------------------------------------------
// | Main [ NO ZUO NO DIE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2010-2017 http://www.bocweb.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: Hanj
// +----------------------------------------------------------------------
 
//----------------------------------
// Main-三方托管交易类
//----------------------------------

class Loan_main {

	public $common  = null;
	public $qdd     = null;
	public $rsa     = null;
	public $qdd_pid = null;
	// ------------------------------------------------------------------------

	/**
	 * Constructor
	 *
	 * @param array
	 */
	public function __construct()
	{
		
		include_once LIBS_PATH."libraries/netcredit/drivers/qdd/qdd.php";
		include_once LIBS_PATH."libraries/netcredit/drivers/qdd/qdd_rsa.php";
		include_once LIBS_PATH."libraries/netcredit/drivers/qdd/qdd_common.php";
 
		$this->common = new qdd_common();
		$this->qdd = new Qdd();
		$this->rsa = new qdd_rsa();
		$this->qdd_pid = $this->qdd->pid();
		$this->CI =& get_instance();
	}

	// 注册
	public function register($user=false) {

		if (! $user) {
			
			return false;
		}

		if($this->common->getAntiState() == 0)
		{
			$RandomTimeStamp = "";
		}
		else if($this->common->getAntiState() == 1)
		{
			$RandomTimeStamp = $this->common->getRandomTimeStamp();
		}

		$data['RegisterType']          = 2;
		$data['AccountType']           = $user['type'];
		$data['Mobile']                = $user['mobile'];
		$data['Email']                 = "";
		$data['RealName']              = $user['realname'];
		$data['IdentificationNo']      = $user['chinaid'];
		$data['LoanPlatformAccount']   = $user['account'];
		$data['PlatformMoneymoremore'] = $this->qdd_pid;
		$data['RandomTimeStamp']       = $RandomTimeStamp;
		$data['Remark1']               = $user['aid'];
		$data['Remark2']               = "";
		$data['Remark3']               = "";
		$data['ReturnURL']             = SITE_URL.'validate/registerReturn';
		$data['NotifyURL']             = SITE_URL.'validate/registerNotify';

		$dataStr = $data['RegisterType'].$data['AccountType'].$data['Mobile'].$data['Email'].$data['RealName']
		         . $data['IdentificationNo'].$data['LoanPlatformAccount'].$data['PlatformMoneymoremore']
		         . $data['RandomTimeStamp'].$data['Remark1'].$data['Remark2'].$data['Remark3'].$data['ReturnURL']
		         . $data['NotifyURL'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);

		$vdata['url']  = $this->qdd->url('registerbind');
		$vdata['data'] = $data;

		$key = 'Cache:register:'.$user['aid'].':'.time();
		$this->CI->cache->save($key, $vdata, 3600);
		$urlkey    = base64_encode($key);
		$re['url'] = SITE_URL.'redirect?k='.urlencode($urlkey);
		$re['data']= false;
		return $re;
	}

	// 充值
	public function recharge($info=false, $mid=false) {

		if (! $info) {
			
			return false;
		}

		if($this->common->getAntiState() == 0)
		{
			$RandomTimeStamp = "";
		}
		else if($this->common->getAntiState() == 1)
		{
			$RandomTimeStamp = $this->common->getRandomTimeStamp();
		}

		$type    = '';
		$FeeType = '';
		// 空.网银充值 2.快捷支付 3.汇款充值 4.企业网银

		if ($info['type'] == 0) {
			
			$type    = 2;
			$FeeType = 2;
		} elseif($info['type'] == 2) {

			$type    = 3;
			$FeeType = 2;
		} elseif($info['type'] == 3) {

			$type = 4;
			$FeeType = 2;
		} 
		
		// 判断是否为企业平台充值
		if ($mid) {
			
			$data['RechargeMoneymoremore']  = $this->qdd_pid;
		} else {

			$data['RechargeMoneymoremore']  = $info['other_account'];
		}
		
		$data['PlatformMoneymoremore']  = $this->qdd_pid;
		$data['OrderNo']                = $info['orderid'];
		$data['Amount']                 = $info['money'];
		$data['RechargeType']           = $type;
		$data['FeeType']                = $FeeType;
		$data['CardNo']                 = "";
		$data['RandomTimeStamp']        = $RandomTimeStamp;
		$data['Remark1']			    = $info['aid'];
		$data['Remark2']			    = intval($mid);
		$data['Remark3']			    = "";
		$data['ReturnURL']  			= SITE_URL.'validate/rechargeReturn';
		$data['NotifyURL']  			= SITE_URL.'validate/rechargeNotify';
		
		$dataStr = $data['RechargeMoneymoremore'].$data['PlatformMoneymoremore'].$data['OrderNo'].$data['Amount']
		         . $data['RechargeType'].$data['FeeType'].$data['CardNo'].$data['RandomTimeStamp'].$data['Remark1']
		         . $data['Remark2'].$data['Remark3'].$data['ReturnURL'].$data['NotifyURL'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);       
		$vdata['url']  = $this->qdd->url('recharge');
		$vdata['data'] = $data;

		$key = 'Cache:recharge:'.$info['aid'].':'.$info['orderid'];
		$this->CI->cache->save($key, $vdata, 3600);
		$urlkey    = base64_encode($key);
		$re['url'] = SITE_URL.'redirect?k='.urlencode($urlkey);
		$re['data']= false;
		return $re;
	}

	// 提现
	public function withdraw($info=false) {

		if (! $info) {
			
			return false;
		}

		if($this->common->getAntiState() == 0)
		{
			$RandomTimeStamp = "";
		}
		else if($this->common->getAntiState() == 1)
		{
			$RandomTimeStamp = $this->common->getRandomTimeStamp();
		}

		$data['WithdrawMoneymoremore']  = $info['other_account'];
		$data['PlatformMoneymoremore']  = $this->qdd_pid;
		$data['OrderNo']                = $info['orderid'];
		$data['Amount']                 = $info['money'];
		$data['FeeQuota']               = $info['fee'];
		$data['CardNo']                 = $this->rsa->encrypt($info['bank_card']);
		$data['CardType']               = 0;
		$data['BankCode']               = $info['bank_code'];
		$data['BranchBankName']         = "";
		$data['Province']               = $info['province_id'];
		$data['City']                   = $info['city_id'];
		$data['RandomTimeStamp']        = $RandomTimeStamp;
		$data['Remark1']			    = $info['aid'];
		$data['Remark2']			    = "";
		$data['Remark3']			    = "";
		$data['ReturnURL']  			= SITE_URL.'validate/withdrawReturn';
		$data['NotifyURL']  			= SITE_URL.'validate/withdrawNotify';
		
		$dataStr = $data['WithdrawMoneymoremore'].$data['PlatformMoneymoremore'].$data['OrderNo'].$data['Amount']
		         . $data['FeeQuota'].$info['bank_card'].$data['CardType'].$data['BankCode'].$data['BranchBankName']
		         . $data['Province'].$data['City'].$data['RandomTimeStamp'].$data['Remark1'].$data['Remark2']
		         . $data['Remark3'].$data['ReturnURL'].$data['NotifyURL'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);

		$vdata['url']  = $this->qdd->url('withdraws');
		$vdata['data'] = $data;

		$key = 'Cache:withdraw:'.$info['aid'].':'.$info['orderid'];
		$this->CI->cache->save($key, $vdata, 3600);
		$urlkey    = base64_encode($key);
		$re['url'] = SITE_URL.'redirect?k='.urlencode($urlkey);
		$re['data']= false;
		return $re;
	}

	// 绑卡
	public function bindCard($info=false) {

		if (! $info) {
			
			return false;
		}

		if($this->common->getAntiState() == 0)
		{
			$RandomTimeStamp = "";
		}
		else if($this->common->getAntiState() == 1)
		{
			$RandomTimeStamp = $this->common->getRandomTimeStamp();
		}
		$info['bank_card'] = '';

		$data['MoneymoremoreId']             = $info['other_account'];
		$data['PlatformMoneymoremore']       = $this->qdd_pid;
		$data['Action']                      = 1;
		$data['CardNo']                      = $this->rsa->encrypt($info['bank_card']);
		$data['WithholdBeginDate']           = '';
		$data['WithholdEndDate']             = '';
		$data['SingleWithholdLimit']         = '';
		$data['TotalWithholdLimit']          = '';
		$data['RandomTimeStamp']             = $RandomTimeStamp;
		$data['Remark1']			         = $info['aid'];
		$data['Remark2']			         = "";
		$data['Remark3']			         = "";
		$data['ReturnURL']  			     = SITE_URL.'validate/fastpayReturn';
		$data['NotifyURL']  			     = SITE_URL.'validate/fastpayNotify';
		$dataStr = $data['MoneymoremoreId'].$data['PlatformMoneymoremore'].$data['Action'].$info['bank_card']
		         . $data['WithholdBeginDate'].$data['WithholdEndDate']
		         . $data['SingleWithholdLimit'].$data['TotalWithholdLimit'].$data['RandomTimeStamp']
		         . $data['Remark1'].$data['Remark2'].$data['Remark3'].$data['ReturnURL'].$data['NotifyURL'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);
 		$data['dataStr']   = $dataStr;
		$vdata['url']  = $this->qdd->url('fastpay');
		$vdata['data'] = $data;

		$key = 'Cache:fastpay:'.$info['aid'].':'.$info['orderid'];
		$this->CI->cache->save($key, $vdata, 3600);
		$urlkey    = base64_encode($key);
		$re['url'] = SITE_URL.'redirect?k='.urlencode($urlkey);
		$re['data']= false;
		
		return $re;
	}

	// 交易投资/转账 单个
	public function transfer($info=false) {

		if (! $info) {
			
			return false;
		}

		if($this->common->getAntiState() == 0)
		{
			$RandomTimeStamp = "";
		}
		else if($this->common->getAntiState() == 1)
		{
			$RandomTimeStamp = $this->common->getRandomTimeStamp();
		}

		$arrloaninfo = array (
		    array(  "LoanOutMoneymoremore"  => $info['other_account']
					, "LoanInMoneymoremore" => $info['to_other_account']
					, "OrderNo"             => $info['orderid']
					, "BatchNo"             => $info['pid']
					, "ExchangeBatchNo"     => ''
					, "AdvanceBatchNo"      => ''
					, "Amount"              => $info['money']
					, "FullAmount"          => $info['full_money']
					, "TransferName"        => '投标'
					, "Remark"              => "用户ID".$info['aid']."投资项目ID".$info['pid']
					, "SecondaryJsonList"   => ""
			)
		);
		$LoanJsonList = json_encode($arrloaninfo);
		$data['LoanJsonList']  			= urlencode($LoanJsonList);
		$data['PlatformMoneymoremore']  = $this->qdd_pid;
		$data['TransferAction']         = 1;
		$data['Action']                 = 1;
		$data['TransferType']           = 1;
		$data['ArrivalTime']            = "";
		$data['NeedAudit']              = "";
		$data['DelayTransfer']          = "";
		$data['RandomTimeStamp']        = $RandomTimeStamp;
		$data['Remark1']			    = $info['aid'];
		$data['Remark2']			    = $info['rids'];
		$data['Remark3']			    = $info['red_package'];
		$data['ReturnURL']  			= SITE_URL.'validate/investReturn';
		$data['NotifyURL']  			= SITE_URL.'validate/investNotify';
		
		$dataStr = $LoanJsonList.$data['PlatformMoneymoremore'].$data['TransferAction'].$data['Action']
		         . $data['TransferType'].$data['ArrivalTime'].$data['NeedAudit'].$data['DelayTransfer']
		         . $data['RandomTimeStamp'].$data['Remark1'].$data['Remark2'].$data['Remark3']
		         . $data['ReturnURL'].$data['NotifyURL'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);

		$vdata['url']  = $this->qdd->url('transfer');
		$vdata['data'] = $data;

		$key = 'Cache:transfer:'.$info['aid'].':'.$info['orderid'];
		$this->CI->cache->save($key, $vdata, 3600);
		$urlkey    = base64_encode($key);
		$re['url'] = SITE_URL.'redirect?k='.urlencode($urlkey);
		$re['data']= false;
		return $re;
	}

	// 奖励金额
	public function reward($info=false) {

		if (! $info) {
			
			return false;
		}

		if($this->common->getAntiState() == 0)
		{
			$RandomTimeStamp = "";
		}
		else if($this->common->getAntiState() == 1)
		{
			$RandomTimeStamp = $this->common->getRandomTimeStamp();
		}

		$arrloaninfo = array();
		if ($info['list']) {
			
			foreach ($info['list'] as $v) {
				
				$tmp = array( "LoanOutMoneymoremore"=> $this->qdd_pid
							, "LoanInMoneymoremore" => $v['other_account']
							, "OrderNo"             => $v['orderid']
							, "BatchNo"             => $v['bid']
							, "ExchangeBatchNo"     => ''
							, "AdvanceBatchNo"      => ''
							, "Amount"              => $v['money']
							, "FullAmount"          => $v['full_money']
							, "TransferName"        => "用户ID".$v['aid']."运营奖励红包"
							, "Remark"              => $v['aid']
							, "SecondaryJsonList"   => ""
					);
				$arrloaninfo[] = $tmp;
			}
		} else {

			return false;
		}

		$LoanJsonList = json_encode($arrloaninfo);
		$data['LoanJsonList']  			= urlencode($LoanJsonList);
		$data['PlatformMoneymoremore']  = $this->qdd_pid;
		$data['TransferAction']         = 3;
		$data['Action']                 = 2;
		$data['TransferType']           = 1;
		$data['ArrivalTime']            = "";
		$data['NeedAudit']              = 1;
		$data['DelayTransfer']          = "";
		$data['RandomTimeStamp']        = $RandomTimeStamp;
		$data['Remark1']			    = 0;
		$data['Remark2']			    = $info['orderid'];
		$data['Remark3']			    = '';
		$data['ReturnURL']  			= SITE_URL.'validate/rewardReturn';
		$data['NotifyURL']  			= SITE_URL.'validate/rewardNotify';
		
		$dataStr = $LoanJsonList.$data['PlatformMoneymoremore'].$data['TransferAction'].$data['Action']
		         . $data['TransferType'].$data['ArrivalTime'].$data['NeedAudit'].$data['DelayTransfer']
		         . $data['RandomTimeStamp'].$data['Remark1'].$data['Remark2'].$data['Remark3']
		         . $data['ReturnURL'].$data['NotifyURL'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);

		$vdata['url']  = $this->qdd->url('transfer');
		$vdata['data'] = $data;

		$key = 'Cache:reward:0:'.$info['orderid'];
		$this->CI->cache->save($key, $vdata, 3600);
		$urlkey    = base64_encode($key);
		$re['url'] = SITE_URL.'redirect?k='.urlencode($urlkey);
		
		// 发送请求
		$ch  = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->qdd->url('transfer'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $html = curl_exec($ch);
        curl_close($ch);

        // return
        $re['data'] = json_decode($html, 1);
		return $re;
	}

	// 交易付息/还款
	public function repay($info=false) {

		if (! $info) {
			
			return false;
		}

		if($this->common->getAntiState() == 0)
		{
			$RandomTimeStamp = "";
		}
		else if($this->common->getAntiState() == 1)
		{
			$RandomTimeStamp = $this->common->getRandomTimeStamp();
		}

		$arrloaninfo = array();
		foreach ($info['list'] as $v) {
			
			$arrloaninfo[] = array(   "LoanOutMoneymoremore"=> $this->qdd_pid
									, "LoanInMoneymoremore" => $v['other_account']
									, "OrderNo"             => $v['orderid']
									, "BatchNo"             => $v['batch_no']
									, "ExchangeBatchNo"     => ''
									, "AdvanceBatchNo"      => ''
									, "Amount"              => $v['money']
									, "FullAmount"          => $v['full_money']
									, "TransferName"        => '还款/付息'
									, "Remark"              => "对用户".$v['aid']."还款/付息，项目标号".$v['pid']
									, "SecondaryJsonList"   => ""
							);

		}
		if (! $arrloaninfo) {
			
			return false;
		}
		$LoanJsonList = json_encode($arrloaninfo);
		$data['LoanJsonList']  			= urlencode($LoanJsonList);
		$data['PlatformMoneymoremore']  = $this->qdd_pid;
		$data['TransferAction']         = 1;
		$data['Action']                 = 1;
		$data['TransferType']           = 2;
		$data['ArrivalTime']            = "";
		$data['NeedAudit']              = 1;
		$data['DelayTransfer']          = "";
		$data['RandomTimeStamp']        = $RandomTimeStamp;
		$data['Remark1']			    = $info['pid'];
		$data['Remark2']			    = "";
		$data['Remark3']			    = "";
		$data['ReturnURL']  			= SITE_URL.'validate/interestReturn';
		$data['NotifyURL']  			= SITE_URL.'validate/interestNotify';
		
		$dataStr = $LoanJsonList.$data['PlatformMoneymoremore'].$data['TransferAction'].$data['Action']
		         . $data['TransferType'].$data['ArrivalTime'].$data['NeedAudit'].$data['DelayTransfer']
		         . $data['RandomTimeStamp'].$data['Remark1'].$data['Remark2'].$data['Remark3']
		         . $data['ReturnURL'].$data['NotifyURL'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);

		$vdata['url']  = $this->qdd->url('transfer');
		$vdata['data'] = $data;

		$key = 'Cache:transfer:'.$info['aid'].':'.$info['orderid'];
		$this->CI->cache->save($key, $vdata, 3600);
		$urlkey    = base64_encode($key);
		$re['url'] = SITE_URL.'redirect?k='.urlencode($urlkey);
		$re['data']= false;
		return $re;
	}

	// 交易审核
	public function transferaudit($info=false) {

		if (! $info) {
			
			return false;
		}

		if($this->common->getAntiState() == 0)
		{
			$RandomTimeStamp = "";
		}
		else if($this->common->getAntiState() == 1)
		{
			$RandomTimeStamp = $this->common->getRandomTimeStamp();
		}

		$LoanNoList = "";
		if ($info['request_nos']) {
			
			$LoanNoList = implode(',', $info['request_nos']);
		} else {

			return false;
		}
		$data['LoanNoList']             = $LoanNoList;
		$data['PlatformMoneymoremore']  = $this->qdd_pid;
		$data['AuditType']              = $info['pay_audit'];
		$data['DelayTransfer']          = "";
		$data['RandomTimeStamp']        = $RandomTimeStamp;
		$data['Remark1']			    = $info['pid'];
		$data['Remark2']			    = $info['pay_money'];
		$data['Remark3']			    = "";
		$data['ReturnURL']  			= SITE_URL.'validate/payauditReturn';
		$data['NotifyURL']  			= SITE_URL.'validate/payauditNotify';
		
		$dataStr = $data['LoanNoList'].$data['PlatformMoneymoremore'].$data['AuditType'].$data['DelayTransfer']
		         . $data['RandomTimeStamp'].$data['Remark1'].$data['Remark2']
		         . $data['Remark3'].$data['ReturnURL'].$data['NotifyURL'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);

		$vdata['url']  = $this->qdd->url('transferaudit');
		$vdata['data'] = $data;

		$key = 'Cache:transferaudit:'.$info['pid'].':'.$info['orderid'];
		$this->CI->cache->save($key, $vdata, 3600);
		$urlkey    = base64_encode($key);
		$re['url'] = SITE_URL.'redirect?k='.urlencode($urlkey);
		$re['data']= false;
		return $re;
	}

	// 用户余额查询
	public function balancequery ($info=false, $type = "", $is_plat=false) {
		
		if (! $info) {
			
			return false;
		}

		$other_account = $this->qdd_pid;
		if (!$is_plat) {

			$other_account = $info['other_account'];
		}
		$data['PlatformId']            = $other_account;
		$data['PlatformType']          = 2;
		$data['QueryType']             = $type;
		$data['PlatformMoneymoremore'] = $this->qdd_pid;;
		
		$dataStr = $data['PlatformId'].$data['PlatformType'].$data['QueryType'].$data['PlatformMoneymoremore'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);
		$url = $this->qdd->url('balancequery');
		$ch  = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $html = curl_exec($ch);
        curl_close($ch);

		$re['url']  = '';
		$re['data'] = $html;
		return $re;
	}

	// 银行列表查询
	public function userBankList ($info=false) {
		
		if (! $info) {
			
			return false;
		}

		$data['PlatformId']            = $info['other_account'];
		$data['PlatformType']          = 2;
		$data['QueryType']             = 2;
		$data['PlatformMoneymoremore'] = $this->qdd_pid;
		$dataStr = $data['PlatformId'].$data['PlatformType'].$data['QueryType'].$data['PlatformMoneymoremore'];

		if($this->common->getAntiState() == 1)
		{
			$dataStr = strtoupper(md5($dataStr));
		}

		$data['SignInfo']  = $this->rsa->sign($dataStr);
		$url = $this->qdd->url('balancequery');
		$ch  = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        $html = curl_exec($ch);
        curl_close($ch);
		$tmp = explode(',', $html);
		$tmp2 = explode('|', $tmp[0]);

		if ($tmp[0]) {
			
			$re['data'] = $this->rsa->decrypt($tmp2[0]);
		}
		// date[]
		$re['url']  = '';
		return $re;
	}

	// 获取银行列表
	public function getBanks() {
		return $this->qdd->bank_list();
	}

	// 获取开户行省份
	public function getProvince () {

		$tmp_list = array();
 		foreach ($this->qdd->citys as $v) {
 			if ($v['province_id'] == "0") {
 				array_push($tmp_list, $v);
 			}
 		}
 		return $tmp_list;
	}

	// 获取开户行城市
	public function getCityList ($fid=0){

		$tmp_list = array();
 		foreach ($this->qdd->citys as $v) {
 			if ($v['province_id'] == "$fid") {
 				array_push($tmp_list, $v);
 			}
 		}
 		return $tmp_list;
	}

	// APP使用的省市列表
	public function getCityListApp (){

		$provinces = array();

		foreach($this->qdd->citys as $key => $value){
		if ($value['province_id'] == 0) {

				$provinces[$value['id']] = $value;
			}
			else {

				$provinces[$value['province_id']]['citylist'][] = $value;
			}
		}
		$provinces = array_values($provinces);
		return $provinces;
	}

	// 获取开户行城市单个
	public function getCity ($id=0){

		if ($id === false or !is_numeric($id)) {
 			return false;
 		}

 		foreach ($this->qdd->citys as $v) {
 			if ($v['id'] == "$id") {
 				return $v['title'];
 			}
 		}
	}

	// 获取银行列表
	public  function getBankList () {

		return $this->qdd->bank_list();
	}

	// 获取银行
	public  function getBank ($code) {

		if ($code ===  false) {
			return false;
		}

		$list = $this->qdd->bank_list();

		foreach ($list as $k => $v) {
			if ($v['id'] == "$code") {
				return $v;
			}
		}
	}
}